import java.util.Scanner;

/**
 * @author ShenTuZhiGang
 * @version 1.0.0
 * @email 1600337300@qq.com
 * @date 2021-09-18 18:03
 */
public class ExamNetEase2021091803 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n0 = scanner.nextLong();
        long n = n0;
        if (n == 0) {
            System.out.println(-1);
            return;
        }
        int count1 = 0, count2 = 0, num = 0;
        while (n != 0) {
            if (n % 2 == 1) {
                count1++;
            }
            num++;
            n /= 2;
        }
        long m = (long) (Math.pow(2, num) - n0);
        while (m != 0) {
            if (m % 2 == 1) {
                count2++;
            }
            m /= 2;
        }
        System.out.println(Math.min(count1, count2 + 1));
    }
}
